var db = require('./db');

//Person元数据
var person_entry = {
	'person_record_id' : '',
	'entry_date':'',
	'author_name':'',
	'author_email':'',
	'author_phone':'',
	'source_name':'',
	'source_date':'',
	'source_url':'',
	'full_name':'',
	'given_name':'',
	'family_name':'',
	'alternate_names':'',
	'profile_urls':'',
	'sex':'',
	'date_of_birth':'',//精度可调
	'age':'',//age可以是个范围
	'home_street':'',
	'home_neighborhood':'',
	'home_city':'',
	'home_state':'',
	'home_postal_code':'',
	'home_country':'',
	'photo_url':'',
	'description':'',
	'event_id' : ''
};

var key_domain_prefix = 'personfinder.pfif.org.person.';

var person = {
	//添加Person信息
	add : function(data,opt){
		var d = new Date();
		data.person_record_id = key_domain_prefix+(d-0);
		data.entry_date = d.toUTCString();
		db.insert('person',data,opt);
	},

	//删除Person信息
	del : function(sobj,opt){
		db.insert('person',sobj,opt);
	},

	//更新Person信息
	update : function(sobj,data,opt){
		db.update('person',sobj,data,opt);
	},

	//获取Person信息
	get : function(sobj,opt){
		db.find('person',sobj,opt)
	}
};

module.exports = person;



